import tkinter as tk
import tkinter.messagebox
root=tk.Tk()
root.title("登入窗口--郭枫2020211001000105") 
root.geometry("400x400+200+200")
username=tk.StringVar()
password=tk.StringVar()
label1=tk.Label(root,text="用户名",bg="gold",width=10,font="宋体,20")
label1.grid(row=1,column=1)
label2=tk.Label(root,text="密码",bg="gold",width=10,font="宋体,20")
label2.grid(row=2,column=1)
input1=tk.Entry(root,width=30,textvariable=username)
input1.grid(row=1,column=2)
input2=tk.Entry(root,width=30,textvariable=password)
input2.grid(row=2,column=2)
def btclick(e):
    u=username.get()
    p=password.get()
    with open(r"E:\Python文件\注册登入\re.txt","r",encoding="utf8")as f:
        for item in f:
            s=eval(item)
           
            if(u==s[0] and p==s[1]):
                tk.messagebox.showinfo(title="提示",message="登入成功")
            else:
                tk.messagebox.showinfo(title="提示",message="登入失败")
button1=tk.Button(root,text="登入",command=btclick,font="宋体,20")
button1.grid(row=3,column=1)
button1.bind("<Button-1>",btclick)
button2=tk.Button(root,text="取消",command=btclick,font="宋体,20")
button2.grid(row=3,column=2)
button2.bind("<Button-1>",btclick)
root.mainloop()
